package com.tianya.portal.common.utils.markdown;

import org.commonmark.node.FencedCodeBlock;
import org.commonmark.node.Node;
import org.commonmark.renderer.html.AttributeProvider;

import java.util.Map;

public class CodeAttributeProvider implements AttributeProvider {
    @Override
    public void setAttributes(Node node, String tagName, Map<String, String> attributes) {
        if (node instanceof FencedCodeBlock) {
            attributes.put("class", "language-" + ((FencedCodeBlock) node).getInfo() + " line-numbers");
        }
    }
}
